import elMenuItem from './el-menu-item.vue';
import elSubmenu from './el-submenu.vue';
import elMenu from './el-menu.vue';

const a = {
    props:{
        tree:{
            type:Array
        }
    },
    components:{
        elMenuItem,
        elSubmenu,
        elMenu
    },
    render(){
        let renderChildren  = (data) =>{
            return data.map(child=>{
                return child.children? 
                <elSubmenu>
                    <div slot="title">{child.title}</div>
                    {renderChildren(child.children)}
                </elSubmenu>:
                <elMenuItem nativeOnClick={()=>{
                    alert(1)
                }}>{child.title}</elMenuItem>
            })
        }
        return <elMenu>
            {renderChildren(this.tree)}
        </elMenu>
    }   
}
export default a ;

